#ifndef MENU_H__INCLUDED
#define MENU_H__INCLUDED

#include "extiface.h"

#pragma once

/**
 * Implement IMenuItems
 */
class Menu : public extensions::IMenuItems
{
	typedef std::vector<extensions::MenuItem> items_t;
public:
	/**
	 * Menu default constructor.
	 */
	Menu()
	{
	}

	/**
	 * Virtual destructor - don't want to be sliced!
	 */
	virtual ~Menu()
	{
		for (items_t::const_iterator i = m_items.begin();
			i < m_items.end();
			++i)
		{
			if ((*i).Type == extensions::miSubmenu && (*i).SubItems != NULL)
			{
				delete (*i).SubItems;
			}
		}
	}

	/**
	 * Add a menu item
	 */
	void AddItem(extensions::MenuItem& item)
	{
		m_items.push_back(item);
	}

	/**
	 * Get the number of MenuItem instances that can be retrieved.
	 */
	virtual int GetItemCount() const
	{
		return m_items.size();
	}

	/**
	 * Get an individual MenuItem instance by index.
	 */
	virtual const extensions::MenuItem& GetItem(int index) const
	{
		if ((size_t)index < m_items.size())
		{
			return m_items[index];
		}

		return m_noitem;
	}

private:
	items_t m_items;
	extensions::MenuItem m_noitem;
};

#endif // #ifndef MENU_H__INCLUDED